package com.wwlwxg.compress;

import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * 不能运行
 */
public class CompressUtil {

	public static void main(String[] args) {
		InputStream resourceAsStream = CompressUtil.class.getClassLoader().getResourceAsStream("my.tar.gz");

		try (InputStream fi = resourceAsStream;
		     InputStream bi = new BufferedInputStream(fi);
		     InputStream gzi = new GzipCompressorInputStream(bi);
		     ArchiveInputStream o = new TarArchiveInputStream(gzi)) {
			System.out.println(o.available());
			System.out.println();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
